*set time +1

At last you have reached home.

Over the next few days, you arrange to sell your goods:

*temp spices_price
*temp dyes_price
*temp metals_price
*temp gems_price
*temp rounding
*temp rounded
*set spices_price (60 + (shrewdness * (2/3)))							
*comment ****60-126
*set rounding "spices_price"
*gosub round
*set dyes_price (92 + (shrewdness * (4/5)))								
*comment ****92-172
*set rounding "dyes_price"
*gosub round
*set metals_price (150 + (shrewdness * (3/2)))						
*comment ****150-300
*set rounding "metals_price"
*gosub round
*set gems_price (((750 - shrewdness) / (150 - shrewdness)) * 66)	
*comment ****330-858
*set rounding "gems_price"
*gosub round

*if (spices>0)
	Spices and incense: ${spices} for ${spices_price} each
	*line_break
*if (dyes>0)
	Dyes and cloth: ${dyes} for ${dyes_price} each
	*line_break
*if (metals > 0)
	Precious metals: ${metals} for ${metals_price} each
	*line_break
*if (gems > 0)
	Gemstones: ${gems} for ${gems_price} each

*temp revenue
*set revenue (((spices * spices_price) + (dyes * dyes_price)) + ((metals * metals_price) + (gems * gems_price)))
*temp total_cost
*set total_cost (((spices_outlay + dyes_outlay) + (metals_outlay + gems_outlay)) + misc_outlay)
*temp profits
*set profits ((revenue + funds) - (total_cost + debt))

Total revenue: ${revenue}

Along with your remaining ${funds} funds, having spent ${total_cost},
*if (debt > 0)
	and with a debt of ${debt},
you've made a profit of ${profits}. 
*temp success_level
*if profits > 2000
	*set success_level "An incredible haul!"
	*goto success_text
*elseif profits > 750
	*set success_level "Not a bad showing, really."
	*goto success_text
*elseif profits > 0
	*set success_level "You hoped you could have done better."
	*goto success_text
*else
	*set success_level "What a disaster."
	*goto success_text
	
*label success_text
${success_level}

*page_break

*share_this_game
	
*goto_scene ending



*label round
*set rounded 0
*temp val
*label roundloop
*set val {rounding}
*if (val - rounded) > 1
	*set rounded +1
	*goto roundloop
*elseif (val - rounded) = 1
	*comment Need to account for rounding an integer value.
	*set rounded +1
	*goto roundfinish
*else
	*label roundfinish
	*setref rounding rounded
	*return